package com.cy1640.damai;

import android.support.v4.app.Fragment;
import android.util.SparseArray;

/**
 * Created by chenyang on 2016/12/12.
 */

public class FragmentFactory {
    public static final int TUIJIAN=0;
    public static final int YANCHU=1;
    public static final int FIND=2;
    public static final int ME=3;

    private static SparseArray<Fragment> fragments=new SparseArray<>();
    static Fragment creatFragment(int index){
        Fragment fragment=fragments.get(index);
        if (fragment==null) {
            switch (index) {
                case TUIJIAN:
                    fragment=new RecommendFragment();
                    break;
                case YANCHU:
                    fragment=new Yanchufragment();
                    break;
                case FIND:
                    fragment=new FindFragment();
                    break;
                case ME:
                    fragment=new MeFragment();
                    break;
            }
            fragments.put(index,fragment);
        }
        return fragment;
    }
}
